/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Goals.Calculations;

import Current.Account;

/**
 * @author Fork
 */
public class OffenseGoals {

    private Integer offenseGoal;
    private Account account;

    public OffenseGoals(Integer offenseGoal, Account account) {
        this.offenseGoal = offenseGoal;
        this.account = account;
    }

    public OffenseGoals(Account account) {
        this.offenseGoal = account.getStats().getOffense();
        this.account = account;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public Integer getOffenseGoal() {
        return offenseGoal;
    }

    public void setOffenseGoal(Integer offenseGoal) {
        this.offenseGoal = offenseGoal;
    }

    Integer calcNeededFEType1Units() {
        Integer result;
        Integer gap = offenseGoal - account.getStats().getOffense();
        Integer fullyEquipedBoost = account.getUnits().getSoldiers().getOffenseIncrease() + account.getArmories().getOffArmory().getSetOffenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().offenseBoost() + account.getRace().offenseBoost() + account.getStructures().getOffFortBonus() + account.getPoints().getStrength()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    Integer calcNeededFEType2Units() {
        Integer result;
        Integer gap = offenseGoal - account.getStats().getOffense();
        Integer fullyEquipedBoost = account.getUnits().getKnights().getOffenseIncrease() + account.getArmories().getOffArmory().getSetOffenseBonus() + account.getBattleUpgrades().getOffUpgrades().getOffUpgrades().getOffenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().offenseBoost() + account.getRace().offenseBoost() + account.getStructures().getOffFortBonus() + account.getPoints().getStrength()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    Integer calcNeededFEType3Units() {
        Integer result;
        Integer gap = offenseGoal - account.getStats().getOffense();
        Integer fullyEquipedBoost = account.getUnits().getBerserkers().getOffenseIncrease() + account.getArmories().getOffArmory().getSetOffenseBonus() + account.getBattleUpgrades().getOffUpgrades().getOffUpgrades().getOffenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().offenseBoost() + account.getRace().offenseBoost() + account.getStructures().getOffFortBonus() + account.getPoints().getStrength()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    Integer calcNeededFEType4Units() {
        Integer result;
        Integer gap = offenseGoal - account.getStats().getOffense();
        Integer fullyEquipedBoost = account.getUnits().getWarriors().getOffenseIncrease() + account.getArmories().getOffArmory().getSetOffenseBonus() + account.getBattleUpgrades().getOffUpgrades().getOffUpgrades().getOffenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().offenseBoost() + account.getRace().offenseBoost() + account.getStructures().getOffFortBonus() + account.getPoints().getStrength()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    public Integer calcNeededOffenseSoldiersGold() {
        Integer neededUnits = calcNeededFEType1Units();

        Integer costPerFullSetUnit = account.getArmories().getOffArmory().getSetCost() + account.getUnits().getSoldiers().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

    public Integer calcNeededOffenseKnightsGold() {
        Integer neededUnits = calcNeededFEType2Units();

        Integer costPerFullSetUnit = account.getArmories().getOffArmory().getSetCost() + account.getUnits().getSoldiers().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

    public Integer calcNeededOffenseBerserkersGold() {
        Integer neededUnits = calcNeededFEType3Units();

        Integer costPerFullSetUnit = account.getArmories().getOffArmory().getSetCost() + account.getUnits().getSoldiers().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

    public Integer calcNeededOffenseWarriorsGold() {
        Integer neededUnits = calcNeededFEType4Units();

        Integer costPerFullSetUnit = account.getArmories().getOffArmory().getSetCost() + account.getUnits().getSoldiers().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }
}
